Change player in javascript game [migrated]
Posted
by
KLUSTER
on Pro Webmasters
See other posts from Pro Webmasters
or by KLUSTER
Published on 2012-06-04T19:36:39Z
Indexed on
2012/06/04
22:47 UTC
Read the original article
Hit count: 164
JavaScript
Game: onClick startbutton > mathrandom for first player who starts the game. 4 Pictures: 2 of it > player1 and player2. another 2> Player turn.
need help: on button click > next player turn
function game(){
var PlayerTurn;
PlayerTurn=parseInt(Math.random()*2);
if(PlayerTurn==0){PlayerTurn=1;window.document.player1.src="Cache/Player3.PNG";}
else{PlayerTurn=0;window.document.player2.src="Cache/Player4.PNG";}
}
Any help is appreciated.
© Pro Webmasters or respective owner